package com.jiyun.wait.controller;


import com.jiyun.pojo.driver.Driver;
import com.jiyun.pojo.order.OrderInformation;
import com.jiyun.result.Result;
import com.jiyun.wait.service.WaitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wait")
public class WaitController {

    @Autowired
    private WaitService waitService;

    //获取等待人数
    @GetMapping("waitPeople")
    public Result waitPeople(){
        return Result.ok(waitService.waitPeople());
    }

    //查询司机信息
    @GetMapping("findSelectDriver")
    public Result findSelectDriver(){
        return waitService.findSelectDriver();
    }

    //查找司机信息
    @PostMapping("selectDriverById")
    public Result selectDriverById(@RequestBody Driver driver){
        return waitService.selectDriverById(driver);
    }

    //取消订单(司机未接受订单)
    @PostMapping("closeOrderNoPeople")
    public Result closeOrderNoPeople(@RequestBody OrderInformation orderInformation){
        return waitService.closeOrderNoPeople(orderInformation);
    }
    //取消订单（司机已经接受订单）
    @PostMapping("closeOrder")
    public Result closeOrder(@RequestBody OrderInformation orderInformation){
       return waitService.closeOrder(orderInformation);
    }

    //根据订单id查询订单
    @PostMapping("selectOrderById")
    public Result selectOrderByOrderId(@RequestBody OrderInformation orderInformation){
        return waitService.selectOrderByOrderId(orderInformation);
    }

    @PostMapping("saveOrderTime")
    public Result saveOrderTime(@RequestBody OrderInformation orderInformation){
        return waitService.saveOrderTime(orderInformation);
    }

    @PostMapping("selectOrderStatus")
    public Result selectOrderStatus(@RequestBody OrderInformation orderInformation){
        return waitService.selectOrderStatus(orderInformation);
    }

    //如果司机接单后中途取消订单执行
    @PostMapping("saveOrder")
    public Result saveOrder(@RequestBody OrderInformation orderInformation){
        return waitService.saveOrder(orderInformation);
    }

    //轮询司机是否到达目的地
    @PostMapping("selectOrderStatusIsArrive")
    public int selectOrderStatusIsArrive(@RequestBody OrderInformation orderInformation){
        return waitService.selectOrderStatusIsArrive(orderInformation);
    }
}
